import Vue from "vue";

import "normalize.css/normalize.css"; // A modern alternative to CSS resets

import "element-ui/packages/theme-chalk/src/index.scss";
// element-ui/src/locale/lang
import "@/styles/index.scss"; // global css
import App from "./App";
import store from "./store";
import router from "./router";
import './assets/fonts/iconfont.css'
import "@/icons"; // icon
import "@/permission"; // permission control

import SaveDraftBox from '@/components-production-management/SaveDraftBox'
Vue.component('SaveDraftBox', SaveDraftBox)
import i18n from "./lang";

// import { Swiper, SwiperSlide } from 'swiper/vue';
// import 'swiper/css';
import "swiper/swiper.min.css"

// 引入echarts
import * as echarts from "echarts";
Vue.prototype.$echarts = echarts;

import $baseurl from '@/api/baseURL'
Vue.prototype.$baseurl = $baseurl;

import moment from "moment"; // 导入moment模块
moment.locale("zh-cn"); // 设置语言 或 moment.lang('zh-cn');
Vue.prototype.$moment = moment; // 赋值使用

import Element from "element-ui";
Vue.use(Element, {
  size: "mini",
});
// 引入拖拽组件
import VueDragResize from 'vue-drag-resize'
Vue.component('vue-drag-resize', VueDragResize)

Vue.config.productionTip = false;
// import 'default-passive-events'
// 图片
import EleUploadImage from "vue-ele-upload-image";
Vue.component(EleUploadImage.name, EleUploadImage);
// 百度地图
import BaiduMap from "vue-baidu-map";
Vue.use(BaiduMap, {
  /* 需要注册百度地图开发者来获取你的ak */
  ak: "sKrOZGXxifZ1r7Ot7Bm1OoBWd6DILGfH"
});
import VueQuillEditor from 'vue-quill-editor'
import { formatTime, getBatchStatus } from '@/utils/utilFn.js';
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.prototype.$formatTime = formatTime;
Vue.prototype.$getBatchStatus = getBatchStatus;
Vue.use(VueQuillEditor);
// window.console.log = function () { };
Vue.directive('tableMove', {
  bind: function (el, binding, vnode) {
    var odiv = el; // 获取当前表格元素  
    var mouseDownAndUpTimer = null;
    var mouseOffset = 0;
    var mouseFlag = false;

    // 添加可拖动样式  
    odiv.querySelector('.el-table__body-wrapper').style.cursor = 'grab';

    odiv.onmousedown = (e) => {
      if (e.which !== 1) return;
      mouseOffset = e.clientX;
      mouseDownAndUpTimer = setTimeout(function () {
        mouseFlag = true;
      }, 1);
    };

    odiv.onmouseup = (e) => {
      if (mouseFlag) {
        mouseFlag = false;
      } else {
        clearTimeout(mouseDownAndUpTimer); // 清除延迟时间  
      }
    };

    odiv.onmouseleave = (e) => {
      mouseFlag = false;
    };

    odiv.onmousemove = (e) => {
      if (e.which !== 1 || !mouseFlag) return;
      const divData = odiv.querySelector('.el-table__body-wrapper');
      if (divData) {
        // 设置水平方向的元素的位置  
        divData.scrollLeft -= (-mouseOffset + (mouseOffset = e.clientX));
      }
    };

    // 阻止默认拖动行为  
    odiv.ondragstart = (e) => {
      e.preventDefault();
    };
  }
});
new Vue({
  el: "#app",
  router,
  store,
  i18n,
  render: h => h(App),
  beforeCreate() {
    Vue.prototype.$bus = this
  }
});
Vue.directive('tableMove', {
  bind: function (el, binding, vnode) {
    var odiv = el; // 获取当前表格元素  
    var mouseDownAndUpTimer = null;
    var mouseOffset = 0;
    var mouseFlag = false;

    // 添加可拖动样式  
    odiv.querySelector('.el-table__body-wrapper').style.cursor = 'grab';

    odiv.onmousedown = (e) => {
      if (e.which !== 1) return;
      mouseOffset = e.clientX;
      mouseDownAndUpTimer = setTimeout(function () {
        mouseFlag = true;
      }, 1);
    };

    odiv.onmouseup = (e) => {
      if (mouseFlag) {
        mouseFlag = false;
      } else {
        clearTimeout(mouseDownAndUpTimer); // 清除延迟时间  
      }
    };

    odiv.onmouseleave = (e) => {
      mouseFlag = false;
    };

    odiv.onmousemove = (e) => {
      if (e.which !== 1 || !mouseFlag) return;
      const divData = odiv.querySelector('.el-table__body-wrapper');
      if (divData) {
        // 设置水平方向的元素的位置  
        divData.scrollLeft -= (-mouseOffset + (mouseOffset = e.clientX));
      }
    };

    // 阻止默认拖动行为  
    odiv.ondragstart = (e) => {
      e.preventDefault();
    };
  }
});
